package www.qiyue.bj;

import com.graphbuilder.curve.NURBSpline;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Null;
import java.math.BigDecimal;
import java.util.Map;

@RestController
public class myCgformUtilController {
    @Autowired
    private JdbcTemplate jdbcTemplate;

    @RequestMapping("bidemo123")
    public String bidemo(){
        String id="297e60c46b9cb63d016b9d4ed2180cd3";
        String acreage="select  sum(acreage) as sum  from ais_rent_unit where data_status_id='01' and house_id=?";
        Map<String,Object> object =jdbcTemplate.queryForMap(acreage,new Object[]{id});
        BigDecimal sum = new BigDecimal(object.get("sum") == null ? "0" : object.get("sum") + "");
        String house = "SELECT acreage from ais_house WHERE id='"+id+"'";
        Map<String,Object>test=jdbcTemplate.queryForMap(house);
        BigDecimal testsum = new BigDecimal(test.get("acreage") == null ? "0" : test.get("acreage") + "");
        int i = sum.compareTo(testsum);
        String str="面积校验成功房屋面积为: "+testsum.toString()+"  租赁单元总面积为: "+sum.toString()+"";
        if (i>0){
            str="面积校验失败房屋面积为: "+testsum.toString()+"  租赁单元总面积为: "+sum.toString()+"";
        }
        String updates="UPDATE ais_house set mjjy='"+str+"' WHERE id='"+id+"'";
        jdbcTemplate.update(updates);
        return null;
    };
}
